package com.jvm;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 描述:
 * 方法反射
 * @author luzhongfu
 * Created by lucky on 2022-03-01 10:58 AM
 */
public class MethodInvokerDemo {

    public void say(String a, int b){
        System.out.println(a + " " + b);
    }

    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        MethodInvokerDemo methodInvokerDemo = new MethodInvokerDemo();

        Method say = MethodInvokerDemo.class.getMethod("say", String.class, int.class);

        Object lucky = say.invoke(methodInvokerDemo, "lucky", 2223);

        System.out.println();
    }
}
